home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 34.zip / BS1 part 34 / FredFish PD 314.adf / Zc / zcsrc.lzh / IOLib / stdio / fclose.c < prev    next >
C/C++ Source or Header  |  1989-05-14  |  450b  |  24 lines

  1. #include <stdio.h>
  2.  
  3. int fclose(fp)
  4.     register FILE *fp;
  5.     {
  6.     register int f;
  7.  
  8.     if(fp == NULL)
  9.         return(EOF);        /* NULL file pointer file */
  10.     f = fp->_flag;
  11.     if((f & (_IOREAD | _IOWRT)) == 0)
  12.         return(EOF);        /* file not open! */
  13.     fflush(fp);
  14.     if(fp->_bsiz != BUFSIZ)        /* throw away non-standard buffer */
  15.         {
  16.         fp->_base = NULL;
  17.         fp->_ptr = NULL;
  18.         fp->_bsiz = 0;
  19.         }
  20.     fp->_flag = 0;            /* clear status */
  21.     f = close(fp->_file);
  22.     return(f ? EOF : 0);
  23.     }
  24.